package com.mobi.cacti.rabbit.connectors;

import java.io.IOException;
import java.security.KeyStore;

import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import android.os.AsyncTask;
import android.util.Log;

import com.mobi.cacti.rabbit.response.Cache;
import com.mobi.cacti.rabbit.utils.MySSLSocketFactory;

public class TicketCountServerConnector extends AbstractServerConnector{

	private String loadingCurcitID;

	public void loadTicketCountForCurcit(String circuitID)
	{
		this.loadingCurcitID = circuitID;
		
		String url = "https://timonitorappuat.trueinternet.co.th/cactimobileservice/tfasrequpdcircuitstatuscount.php";
		String xmlData =
				"<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
						"<ReqTFASCirCuitCount>" +
						"<ReqSessionID>"+Cache.getRequestSessionID()+"</ReqSessionID>" +
						"<AppUser>COMi</AppUser> " +
						"<AppPass>b5d864cdeb699ebb3d17a6ff70c3aa5e</AppPass>" +
						"<CircuitID>"+loadingCurcitID+"</CircuitID> " +
						"</ReqTFASCirCuitCount>";

		this.execute(url,xmlData);

	}

	@Override
	protected void onPostExecute(String result) {
		
		
		
		String[] resultArray = new String[]{loadingCurcitID,result};
		delegate.serverConnectorFinishBackgroundTask(this,resultArray);
	};

}
